package com.lcxw.hxzbapi.controller.paycontroller;

import com.lcxw.hxzbapi.entity.requestBean.GetVipBuyOrderInfoReqWepay;
import com.lcxw.hxzbapi.entity.requestBean.GetWePayOrderReq;
import com.lcxw.hxzbapi.entity.response.Response;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.Map;
import java.util.TreeMap;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jdom.JDOMException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/wxpay")
public class WxPayController {

    @Resource
    WxPayRealization wxPayRealization;

    //获取订单详情接口
    @PostMapping("/getOrderInfo")
    public Response getWePayOrderInfo(@RequestBody GetWePayOrderReq getWePayOrderReq,
        HttpServletRequest request) {
        String remoteAddr = request.getRemoteAddr();
        return wxPayRealization.getWePayOrderInfo(getWePayOrderReq, remoteAddr);
    }

    //微信回调接口
    @PostMapping("/callback")
    public void wxpayCallback(HttpServletRequest request, HttpServletResponse response)
        throws IOException, JDOMException {
        wxPayRealization.dealWxpayCallback(request, response);
    }

    //获取vip购买订单详情接口
    @PostMapping("/vip/orderInfo/get")
    public Response getVipOrderInfo(
        @RequestBody GetVipBuyOrderInfoReqWepay getVipBuyOrderInfoReqWepay,
        HttpServletRequest request) {
        String remoteAddr = request.getRemoteAddr();
        return wxPayRealization.getVipOrderInfo(getVipBuyOrderInfoReqWepay, remoteAddr);
    }
}
